package com.peacebird.utils.file;


import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class FileUtil {


    static SimpleDateFormat sdfPathName = new SimpleDateFormat("yyyyMM");
    static SimpleDateFormat sdfFileName = new SimpleDateFormat("yyyyMMdd");

    public static List<String> getFileNames(String filepath ){
        List<String> fileNameList = new ArrayList<>();
        //File类型可以是文件也可以是文件夹
        File file = new File(filepath);
        File[] fileList = file.listFiles();
        for (int i = 0; i < fileList.length; i++) {
            //判断是否为文件
            if (fileList[i].isFile()) {
                fileNameList.add(fileList[i].getName());
            }
        }
        return fileNameList;
    }

    public static Boolean removeFile(String filePath){
        File file = new File(filePath);
        if (!file.isDirectory()) {
            file.delete();
        }
        return true;
    }

}
